<template>
  <!-- 发现好歌单 -->
  <div class="musicList">
    <div class="musicTop">
      <div class="musicTopTitle">发现好歌单</div>
      <div class="musicTopMore">查看更多</div>
    </div>
    <div class="mList">
      <router-link
        :to="{ path: '/viewList', query: { id: item.id } }"
        class="mItem"
        v-for="(item, index) in mList"
        :key="item.id"
      >
        <svg class="icon" aria-hidden="true">
          <use xlink:href="#icon-huo"></use>
        </svg>
        <span class="mItem_heat"> {{ `${item.trackCount}万` }}</span>
        <div class="mItemWrap">
          <img :src="item.picUrl" :alt="item.name" />
        </div>
        <span class="mItem_text">{{ item.name }}</span>
      </router-link>
    </div>
  </div>
</template>

<script>
import { onMounted, reactive, getCurrentInstance } from 'vue'
export default {
  name: 'MusicList',
  setup() {
    const mList = reactive([])
    const { proxy } = getCurrentInstance()
    onMounted(() => {
      proxy.$axios
        .get('http://localhost:3000/personalized?limit=10')
        .then((res) => {
          let { result } = res.data
          console.log(result)
          mList.push(...result)
        })
    })
    return {
      mList,
    }
  },
}
</script>
<style lang="less" scoped>
.musicList {
  .musicTop {
    height: 0.6rem;
    padding: 0 0.2rem;
    display: flex;
    justify-content: space-between;
    .musicTopTitle {
      font-size: 0.4rem;
      color: #000;
      font-weight: 800;
      line-height: 0.6rem;
    }
    .musicTopMore {
      width: 1.2rem;
      height: 0.3rem;
      padding: 0.1rem 0.2rem;
      line-height: 0.3rem;
      font-size: 0.1rem;
      border: 1px solid #ccc;
      border-radius: 0.4rem;
      text-align: center;
    }
  }
  .mList {
    overflow-x: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .mItem {
      position: relative;
      .mItem_heat {
        height: 0.3rem;
        line-height: 0.3rem;
        color: red;
        position: absolute;
        top: 0.15rem;
        right: 0.1rem;
        font-size: 0.05rem;
      }
      .icon {
        position: absolute;
        top: 0.1rem;
        right: 0.8rem;
        color: red;
        //   top: 0;
        //   height: 0;
      }
      .mItemWrap {
        display: flex;
        padding-left: 0.2rem;
        margin-bottom: 0.2rem;
        // &:first-child {
        //   padding-left: 0;
        // }
        img {
          max-width: 2rem;
          height: auto;
          border-radius: 0.3rem;
        }
      }
      .mItem_text {
        font-size: 0.05rem;
        color: #000;
        padding: 0.2rem;
        overflow: hidden;
        text-overflow: ellipsis;
        -webkit-line-clamp: 2;
        word-wrap: break-word;
        word-break: break-all;
        white-space: normal;
      }
    }
  }
}
</style>
